#ifndef NWayTree_NWayTree_h
#define NWayTree_NWayTree_h

/*
 * Uncomment one of these sets of constants for different tree types.
 */

#define POINTERS_PER_NODE   256
#define LEVELS              8
#define BITS_PER_DECISION   8
#define BITMASK             0xff

//#define POINTERS_PER_NODE   16
//#define LEVELS              16
//#define BITS_PER_DECISION   4
//#define BITMASK             0xf

//#define POINTERS_PER_NODE   4
//#define LEVELS              32
//#define BITS_PER_DECISION   2
//#define BITMASK             0x3

//#define POINTERS_PER_NODE   2
//#define LEVELS              64
//#define BITS_PER_DECISION   1
//#define BITMASK             0x1

/*
 * Tree structures
 */

typedef struct TreeNode {
    struct TreeNode *pointers[POINTERS_PER_NODE];
} TreeNode;

typedef struct Tree {
    TreeNode *root;
} Tree;

/*
 * Public functions
 */

int treeInit(Tree *tree);
int treeInsert(Tree *tree, long long int n);
int treeFind(Tree *tree, long long int n);

/*
 * Private functions
 */

TreeNode *createTreeNode();
unsigned char getNibble(unsigned long long number, int position);

#endif
